---
title: clsAgency
summary: API reference for clsAgency.
status: draft
owner: SAIF Corporation
last_reviewed: 2026-08-21
library: SAIF.Business.View.Policy
reference_type: embedded
---

# clsAgency

`clsAgency` projects the agency-of-record snapshot attached to a policy. `clsPolicyData` loads it lazily through `pk72846_view_policy.getAgency`, and consumers use it for producer identity, agency contact information, and policy-display enrichment. The object also records a business-object error when no agency row exists and masks telephone, address, email, and country fields for demo users.

## Purpose
- Represent the agency and producer snapshot attached to a policy so callers can display agency-of-record details without issuing separate ad hoc queries.
- Retrieve agency data through the policy-view Oracle package and preserve the policy number that requested the snapshot.
- Record the missing-row condition as a "No data found" object error instead of silently returning fabricated data ([BR-VP-025](../../business-rules.md#br-vp-025-missing-agency-row-records-a-no-data-found-error)).
- Apply demo masking to contact and location fields for demo-user access levels ([BR-VP-010](../../business-rules.md#br-vp-010-demo-users-see-masked-data)).

## Context
- Namespace: `SAIF.Business.View.Policy`
- Assembly/package: `SAIF.Business.View.Policy` (embedded)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `GetAgency` | `Public Shared Function GetAgency(ByVal inDataportal As IDataPortalInfo, ByVal inPolicyNum As Decimal) As clsAgency` | Retrieves the agency snapshot for a policy using the default access-level context. |
| `GetAgency` | `Public Shared Function GetAgency(ByVal inCriteria As Criteria) As clsAgency` | Retrieves the agency snapshot from a caller-supplied criteria object so masking and policy-number inputs can be preserved. |
| `AgencyName` | `Public ReadOnly Property AgencyName() As String` | Returns the agency display name, collapsing non-SAIF names to a generic demo label for masked users ([BR-VP-010](../../business-rules.md#br-vp-010-demo-users-see-masked-data)). |
| `AgentName` | `Public ReadOnly Property AgentName() As String` | Returns the producer display name, again replacing it with a generic demo label for masked users ([BR-VP-010](../../business-rules.md#br-vp-010-demo-users-see-masked-data)). |
| `AgencySeqNum` | `Public ReadOnly Property AgencySeqNum() As Decimal` | Exposes the agency identifier used by authorization and policy-display code. |
| `AgentNum` | `Public ReadOnly Property AgentNum() As Decimal` | Exposes the producer identifier used by agent authorization paths. |
| `Address` | `Public ReadOnly Property Address() As clsAddress` | Returns the address object populated from the retrieved agency row for callers that need a structured address representation. |
| `Address1` | `Public ReadOnly Property Address1() As String` | Returns the primary street line, with demo masking applied when required ([BR-VP-010](../../business-rules.md#br-vp-010-demo-users-see-masked-data)). |
| `Address2` | `Public ReadOnly Property Address2() As String` | Returns the secondary street line, blanked for demo users. |
| `CityStateZipFormatted` | `Public ReadOnly Property CityStateZipFormatted() As String` | Formats the city/state/zip triplet into a display-ready location string. |
| `Email` | `Public ReadOnly Property Email() As String` | Returns the agency email address or the masking constant for demo users ([BR-VP-010](../../business-rules.md#br-vp-010-demo-users-see-masked-data)). |
| `PhoneFormatted` | `Public ReadOnly Property PhoneFormatted() As String` | Returns a display-ready agency phone number, substituting a demo number for masked users ([BR-VP-010](../../business-rules.md#br-vp-010-demo-users-see-masked-data)). |
| `Country` | `Public ReadOnly Property Country() As String` | Returns the stored country value, which is replaced with a generic demo value when masking is active ([BR-VP-010](../../business-rules.md#br-vp-010-demo-users-see-masked-data)). |
| `PolicyNum` | `Public ReadOnly Property PolicyNum() As Decimal` | Echoes the policy that requested this agency snapshot so callers can correlate the child object back to its parent aggregate. |
| `IsDemoUser` | `Public ReadOnly Property IsDemoUser() As Boolean` | Indicates whether this agency instance should return masked data for demo external-user access levels. |

## Behavioral notes
- `BeforeRetrieve` calls Oracle procedure `pk72846_view_policy.getAgency` with `apolicynum`.
- `AfterRetrieve` adds `NoDataFoundError` with the message `No data found` when the result set is empty ([BR-VP-025](../../business-rules.md#br-vp-025-missing-agency-row-records-a-no-data-found-error)).
- `Fill` masks producer phone, street, city, country, county, fax, state, zip, phone, and email values for demo users ([BR-VP-010](../../business-rules.md#br-vp-010-demo-users-see-masked-data)).
- The type also hydrates an internal `clsAddress` object so callers can use either field-level properties or the structured address child.

## Constraints and usage notes
- This page documents only members declared in `clsAgency`; inherited members from `clsBusinessBase` are not included.
- The class is read-only; its criteria returns empty SQL for create/insert/update/delete operations.
- Demo masking is triggered for demo agent, demo group, demo policyholder, demo loss-control, and demo auditor access levels.

## Sources
- `SAIF.Business.View.Policy/clsAgency.vb`
